# import datetime


from elasticsearch import Elasticsearch

es = Elasticsearch("http://localhost:9200")

doc = [
    {'index':{'_index':'es_python','_type':'_doc','_id':1}},
    {'name':'赵云','age':25,'sex':'male','birthday':'1995-01-01','salary':8000},
    {'index':{'_index':'es_python','_type':'_doc','_id':2}},
    {'name':'张飞','age':24,'sex':'male','birthday':'1996-01-01','salary':8000},
    {'create':{'_index':'es_python','_type':'_doc','_id':3}},
    {'name':'关羽','age':23,'sex':'male','birthday':'1996-01-01','salary':8000},
]
es.bulk(index='es_python',doc_type='_doc',body=doc)

body = {
    'from': 0,  # 从0开始
    'size': 2  # 取2个数据。类似mysql中的limit 0, 20。 注：size可以在es.search中指定，也可以在此指定，默认是10
}

print(es.search(index='es_python', body=body))
